<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

?>

<form action="index2.php" method="post" name="adminForm">

    <table cellpadding="4" cellspacing="0" border="0" width="100%">
        <tr>
  			<td width="100%" class="sectionname">Projects</td>
  			<td nowrap="nowrap">
				<fieldset>
					<legend>Filter</legend>
					<?php $this->plugin("leagueman_list", "leagues",	"league",	$this->defaults["league_id"],	true);?>
					<?php $this->plugin("leagueman_list", "seasons",	"season", 	$this->defaults["season_id"],	true);?>
					<?php $this->plugin("leagueman_list", "templates", 	"template",	$this->defaults["template"], 	true);?>
					<?php $this->plugin("leagueman_list", "finish",		"finished",	$this->defaults["finished"],	true);?>
				</fieldset>
            </td>
  	    </tr>
    </table>
    
	<table class="adminlist">
  	    <tr>
			<th>&nbsp;</th>
  		    <th width="20">
  			    <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->rows ); ?>);" />
  		    </th>
            <th align="left">Id</th>
  		    <th width="30%" class="title">Name</th>
            <th width="20%">Shortcuts</th>
  		    <th width="15%">Category</th>
  		    <th width="15%">Season</th>
            <th width="5%">Published</th>
  		    <th width="5%">Finished</th>
  	    </tr>
<?php
		$k = 0;
		$i = 0;
		foreach($this->rows AS $row) {
			
			$project = LM::getLMTable("Project");
			$project->populate($row);
			
			$k = 1 - $k;
            
            $task1	= $project->getPublished() ? 'unpublish' : 'publish';
			$img1	= $project->getPublished() ? 'tick.png' : 'publish_x.png';
			
			$task2	= $project->getFinished() ? 'unfinish' : 'finish';
			$img2	= $project->getFinished() ? 'tick.png' : 'publish_x.png';
			
			$task3 	= 'open';
			$img3	= 'folder.gif';
			if($this->project instanceof LM_Table_Project && $this->project->getID() == $row->project_id){
				$task3	= 'close';
				$img3	= 'folder-open.gif';
			}
			
?>
			<tr class="<?php echo "row$k"; ?>">
				<td align="center">
					<a href="#<?php echo $task3;?>" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $task3;?>')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: <?php echo ucfirst($task3);?> this Project!')">
						<img src="../components/com_leagueman/images/<?php echo $img3;?>" border="0" alt="" />
					</a>
				</td>
				<td align="center"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $project->getID(); ?>" onclick="isChecked(this.checked);" /></td>
                <td><b><?php echo $project->getID(); ?></b></td>
				<td>
					<a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: Edit this Project!')">
						<?php echo htmlspecialchars($project->getName(), ENT_QUOTES); ?>
					</a>			
				</td>
                <td>
					<a href="#teams" onclick="return listItemTask('cb<?php echo $i;?>','teammap')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: Show assigned Teams of Project!')">
						<img src="../includes/js/ThemeOffice/db.png" alt="Teams" title="teams" border="0"/>
					</a>
					&nbsp;
					<a href="#rounds" onclick="return listItemTask('cb<?php echo $i;?>','rounds')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: Roundmanager')">
						<img src="../includes/js/ThemeOffice/component.png" alt="Rounds" title="Rounds" border="0" />
					</a>
					&nbsp;
					<a href="#matrix" onclick="return listItemTask('cb<?php echo $i;?>','matrix')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: Enter the Matrix!')">
						<img src="../includes/js/ThemeOffice/mainmenu.png" alt="Matches" title="Matches" border="0" />
					</a>
					&nbsp;
					<a href="#matches" onclick="return listItemTask('cb<?php echo $i;?>','matches')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: Resultmanager!')">
						<img src="../includes/js/ThemeOffice/edit.png" alt="Results" title="Results" border="0" />
					</a>
					&nbsp;
					<a href="#leagutable" onclick="return listItemTask('cb<?php echo $i;?>','leaguetable')">
						<img src="../includes/js/ThemeOffice/content.png" alt="Leagutable" title="Leaguetable" border="0" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: Show Leaguetable')"/>
					</a>
				</td>
				<td><?php echo $row->league_name; ?></td>
			    <td align="center"><?php echo $row->season_name; ?></td>
                <td align="center">
                    <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $task1;?>')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: <?php echo $task1;?> this Project!')">
                        <img src="images/<?php echo $img1;?>" width="12" height="12" border="0" alt="" />
                    </a>
                </td>
				<td align="center">
                    <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $task2;?>')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $project->getName();?></b>: <?php echo $task2;?> this Project!')">
                        <img src="images/<?php echo $img2;?>" width="12" height="12" border="0" alt="" />
                    </a>
                </td>
            </tr>
<?php
			$i++;
        } 
?>
    </table>
	
	<?php echo $this->pageNav->getListFooter(); ?>
    
	<input type="hidden" name="option" value="com_leagueman" />
    <input type="hidden" name="act" value="projects" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
</form>